package com.life.view;

import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.JTextField;

public class TextFieldAdapter extends AbstractAdapter implements FocusListener {

	JTextField theTextField = null;
	
	public TextFieldAdapter(JTextField textField)
	{
		theTextField = textField;
		theTextField.addFocusListener(this);
	}
	
	@Override
	public Object get() {
		return theTextField.getText();
	}

	@Override
	public void setEnabled(boolean value) {
		theTextField.setEnabled(value);
		theTextField.setEditable(value);

	}

	public void focusGained(FocusEvent arg0) {
		System.out.println("FOCUS GAINED"+theTextField.getName());
		setChanged();
		notifyObservers();
		
	}

	public void focusLost(FocusEvent arg0) {
		System.out.println("FOCUS LOST"+theTextField.getName());
		setChanged();
		notifyObservers();
	}

	@Override
	public void set(Object data) {
		// TODO Auto-generated method stub
		
	}

}
